<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        function deepClone(source) {
            if (typeof source !== 'object') {
                console.error('sour不是一个对象')
                return
            }
            let newObj = source instanceof Array ? [] : {}
            for (let key in source) {
                if (typeof source[key] === 'object') {
                    newObj[key] = deepClone(source[key])
                } else {
                    newObj[key] = source[key]
                }
            }

            return newObj
        }
        console.log(deepClone([1, {
            a: 2,
            b: [3, 4, {
                c: 4
            }]
        }]))
    </script>
</body>

</html>